# 导包
from api.login import LoginAPI
from config import PRO_PATH


# 创建测试类
class TestLoginAPI:
    # r为随机小数
    def test01_image_code(self):
        response = LoginAPI().get_image_code(r=0.123456)
        # print(response.status_code)
        assert 200 == response.status_code
        # print(response.content)
        with open(PRO_PATH + "/image/image_code.png", "wb") as f:
            f.write(response.content)

    # r为随机整数
    def test02_image_code(self):
        response = LoginAPI().get_image_code(r=123456)
        # print(response.status_code)
        assert 200 == response.status_code
        # print(response.content)

    # r为随机字符串
    def test03_image_code(self):
        response = LoginAPI().get_image_code(r="abcdef")
        # print(response.status_code)
        assert 400 == response.status_code
        # print(response.content)

    # r为空
    def test04_image_code(self):
        response = LoginAPI().get_image_code(r="")
        # print(response.status_code)
        assert 404 == response.status_code
        # print(response.content)